<template>
	<view class="bz-detail page-bg">
		<view class="my-obj-detail" v-if="obj">
			<view class="mo-top-img">
				<u-image width="150rpx" height="150rpx" :src="`${staticUrl}/other/jzbx-detail-top.png`"></u-image>
				<view class="img-text">{{obj.reimMoney}}元</view>
			</view>

			<view class="mo-main">
				<view class="mo-row">
					<view class="r-title">记账状态</view>
					<view class="r-con">{{obj.isCheck}}</view>
				</view>
				<view v-if="obj.isCheck == '已拒绝'" class="mo-row">
					<view class="r-title">拒绝原因</view>
					<view class="r-con">{{obj.refuseReason}}</view>
				</view>
				<view class="mo-row" v-if="obj.payTime">
					<view class="r-title">报账时间</view>
					<view class="r-con">{{datatime(obj.payTime )}}</view>
				</view>
				<view class="mo-row">
					<view class="r-title">记账类型</view>
					<view class="r-con">{{obj.moneyTypeName}}</view>
				</view>

				<view class="mo-row" v-if="obj.plateNum">
					<view class="r-title">车牌号码</view>
					<view class="r-con">{{obj.plateNum}}</view>
				</view>
				<view class="mo-row" v-if="obj.payWay">
					<view class="r-title">支付方式</view>
					<view class="r-con">{{obj.payWay}}</view>
				</view>
				<view class="mo-row" v-if="obj.reimMoney">
					<view class="r-title">支付金额</view>
					<view class="r-con">{{obj.reimMoney}}</view>
				</view>
				<view class="mo-row">
					<view class="r-title">备注</view>
					<view class="r-con">{{obj.remark?obj.remark:'无'}}</view>
				</view>
				<view class="mo-row" v-if="obj.reimMoneyDetail">
					<view class="r-title">报账详情</view>
					<view class="r-con">{{obj.reimMoneyDetail}}</view>
				</view>
			
				
				
				
				<view class="mo-row">
					<view class="r-title"></view>
					<view class="r-con">
						<u-upload :file-list="flist" :max-count="flist.length" :show-progress="false"
							:deletable="false"></u-upload>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				staticUrl: this.C.staticNetUrl,
				// 报账详情
				obj: null,
				// 图片预览列表
				flist: []
			}
		},
		onLoad(e) {
			this.getBzDetail(e.id);
		},
		methods: {
			// 时间格式
			datatime(e){
				let originalDateTimeString = e;
				let date = new Date(originalDateTimeString);
				
				let year = date.getFullYear();
				let month = String(date.getMonth() + 1).padStart(2, '0');
				let day = String(date.getDate()).padStart(2, '0');
				let hours = String(date.getHours()).padStart(2, '0');
				let minutes = String(date.getMinutes()).padStart(2, '0');
				let seconds = String(date.getSeconds()).padStart(2, '0');
				
				let formattedDateTimeString = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
				return formattedDateTimeString
			},
			// 获取-报账详情
			async getBzDetail(id) {
				const that = this;

				let res = await that.$u.api.getBzDetail({
					id: id
				});
				if (res.code == 1) {
					let o = res.data;

					if (o) {
						that.obj = o;

						// 处理图片
						let flist = [];
						if (o.reimVoucherUrl) {
							let fs = o.reimVoucherUrl.split(',');
							fs.forEach(it => {
								flist.push({
									id: it.split('=')[0],
									url: it.split('=')[1] ? that.C.imgUrl + it.split('=')[1] :
										'https://cba360.com/' + it.split('=')[0]
								});
							});
						}
						that.flist = flist;
					}
				}
			},
		}
	}
</script>

<style>
	.bz-detail {
		background-color: #f3f3f3;
		padding-top: 2rpx;
	}
</style>